package com.example.demo.util;

import java.util.List;
import java.util.Map;

public class SQLUtil {

    public SQLUtil(){
        throw new RuntimeException();
    }

    public static String replaceWhereParameters(String where, List<Map<String, String>> data) {
        if (data == null || data.isEmpty()) {
            return " 1=1 ";
        }
        for (Map<String, String> map : data) {
            for (Map.Entry<String, String> entry : map.entrySet()) {
                String key = "#{" + entry.getKey() + "}";
                String value = entry.getValue();
                where = where.replace(key, "'" + value + "'");
            }
        }
        return where;
    }
}